package graphics;

import graphics.rasterizing.TransformedTriangle;
import graphics.rasterizing.model.Model;
import graphics.rasterizing.model.Triangle;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class SimpleModel implements Model {
	Collection<Triangle> _triangles = new ArrayList<Triangle>();

	public SimpleModel() {

	}

	public SimpleModel(Collection<Triangle> tries) {
		_triangles = new ArrayList<Triangle>(tries);
	}

	public void add(Triangle tri) {
		_triangles.add(tri);
	}

	@Override
	public Collection<Triangle> getTriangles() {
		return new ArrayList<Triangle>(_triangles);
	}

	@Override
	public Iterator<Triangle> getIterator() {
		return getTriangles().iterator();
	}

	@Override
	public Model transform(float[][] transformation) {
		SimpleModel rv = new SimpleModel();
		for(Triangle t : _triangles)
			rv.add(new TransformedTriangle(t, transformation));
		return rv;
	}

}
